package cn.javase.base.io._05_对象流;

import org.junit.jupiter.api.Test;

import java.io.*;

public class _对象流测试 {

    @Test
    public void test() throws IOException, ClassNotFoundException {
        String path = "D:\\Code\\study\\JavaCode\\JavaSEDemo\\base\\src\\main\\java\\cn\\javase\\base\\io\\_05_对象流\\object";
        // 写对象
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(path));
        Student stu = new Student("张三", 23);
        oos.writeObject(stu);
        oos.flush();
        oos.close();
        // 读对象
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(path));
        Student object = (Student)ois.readObject();
        System.out.println(object.getAge() + object.getName() + object.getGender());
    }

}
